package com.pet.server.ext.action.home;


import java.util.ArrayList;
import java.util.List;

import com.pet.server.ext.ActionBase;
import com.pet.server.ext.ApiError;
import com.pet.server.ext.Result;
import com.pet.server.ext.business.MallBusiness;
import com.pet.server.ext.constants.BaseAttribute;
import com.pet.server.ext.data.Campaign;
import com.pet.server.ext.data.Constant;
import com.pet.server.ext.data.ConstantUi;
import com.pet.server.ext.service.UserService;
import com.pet.server.ext.util.Parameters;
import com.pet.server.ext.util.cache.ConstantUtil;

import net.sf.json.JSONObject;
/**
 * 商城首页 /rest/2.0/home/mall
 * */
public class Mall extends ActionBase{
	public Integer article_id;
	public String wechat="0";
	public Mall(){
		 needCheckAuth =false;
	}
	
	@Override
	public void initParameters(Parameters params) throws ApiError {	
		
		
		
		
		
	}
	
	@Override
	public Result invokeService() throws ApiError {

		Result result = new Result();
		
		UserService userService = new UserService();
		
		
		List<Constant> clist =null;
		
		
		Constant home = ConstantUtil.getInstance().findConstant("001006");
		if(home!=null){
			clist=home.getList();
		}else{
			 clist = new ArrayList<>();
			Constant c = new Constant();
			c.conts_name="帮你识货";
			c.code="001006001";
			Constant c1 = new Constant();
			c1.conts_name="低价特惠";
			c1.code="001006004";
			Constant c2 = new Constant();
			c2.conts_name="高端进口";
			c2.code="001006002";
			Constant c3 = new Constant();
			c3.conts_name="零食专柜";
			c3.code="001006003";
			clist.add(c);
			clist.add(c1);
			clist.add(c2);
			clist.add(c3);
		}
		
		List<Campaign> list = userService.queryCampaign(BaseAttribute.pay_type.banner.toString(), 3);
		
		JSONObject o = MallBusiness.JsonData(list, clist);
		
	    
		result.put("data", o);
		return result;
	
	}


}
